﻿#include "setting.h"


setting::setting()
{

}


setting::setting(QWidget *parent):QWidget(parent){
    setFixedSize(1100,900);
    m_player = new QMediaPlayer(this);
    music_path1 = "qrc:/new/prefix1/music/jige.mp3";
    music_path2 = "qrc:/new/prefix1/music/cao kun.mp3";
    QSlider *slider = new QSlider(Qt::Horizontal,this);
}

void setting::paintEvent(QPaintEvent *event){
    if(select_view==3){
        //QMediaPlayer *m_player = new QMediaPlayer(this);
       // QString music_path = "qrc:/new/prefix1/music/jige.mp3";
        QPushButton *music1=new QPushButton("选择音乐1",this);
        QPushButton *music2=new QPushButton("选择音乐2",this);
        QPushButton *null=new QPushButton("关闭音乐",this);

        music1->move(400,300);
        music2->move(400,500);
        null->move(400,700);

        music1->show();
        music2->show();
        null->show();

        connect(music1,&QPushButton::clicked,this,[=](){
            m_player->setMedia(QUrl(music_path1));
            m_player->setVolume(10);
            m_player->play();
        });
        connect(music2,&QPushButton::clicked,this,[=](){
            m_player->setMedia(QUrl(music_path2));
            m_player->setVolume(10);
            m_player->play();
        });
        connect(null,&QPushButton::clicked,this,[=](){
            m_player->stop();
        });

        QSlider *slider = new QSlider(Qt::Horizontal,this);
        slider->setRange(0, 100);
        slider->setValue(50);
        slider->move(500,500);
        //slider->show();

        QPushButton *bottom=new QPushButton("点击回到页面",this);
        QFont font;
        font.setPointSize(20);
        bottom->setFont(font);
        bottom->setGeometry(400,800,250,70);
        bottom->show();
        connect(bottom,&QPushButton::clicked,this,[](){
            select_view=0;
        });
    }
}
